package com.hs.sfzy.controller;

import com.github.pagehelper.PageInfo;
import com.hs.sfzy.entity.PsyTest;
import com.hs.sfzy.service.PsyTestService;
import com.hs.sfzy.until.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName PsyTestController
 * @Description TODO
 * @Author wangzhihao
 * @Date 2025年08月18日 11:55
 * @Version 1.0
 */
@RestController
@RequestMapping("PsyTest")
public class PsyTestController {
    @Autowired
    private PsyTestService psyTestService;
    @GetMapping("{userId}")
    public R selectById(@PathVariable("userId") int userId){
        List<PsyTest> psyTests = psyTestService.selectById(userId);
        return R.ok(psyTests);
    }
    @GetMapping("selectByName")
    public R selectByName(PsyTest psyTest,
                          @RequestParam(required = false,defaultValue = "1")int pageNum,
                          @RequestParam(required = false,defaultValue = "3")int pageSize){
        PageInfo<PsyTest> psyTestPageInfo = psyTestService.selectByName(psyTest, pageNum, pageSize);
        return R.ok(psyTestPageInfo);
    }
    @GetMapping("ids")
    public R selectId(int id){
        PsyTest psyTest = psyTestService.selectId(id);
        return R.ok(psyTest);
    }

}
